<?php
/**
 * Created by PhpStorm.
 * User: idcu
 * Date: 2016/3/12
 * Time: 13:48
 */
namespace Crm\Model;
use IDCU\Model\RelationModel;

class OrderModel extends RelationModel
{
    protected $_auto = array(
        array('create_time','time',1,'function'),
        array('BEGIN_USER','getUserId',1,'function')
    );

    protected $_link = array(
        'Department' => array(
            'mapping_type'  => self::BELONGS_TO,
            'class_name'    => 'Department',
            'mapping_name'  => 'department',
            'foreign_key'   => 'BEGIN_USER',
        )
    );

    protected function _after_select(&$result, $options)
    {
        parent::_after_select($result, $options); // TODO: Change the autogenerated stub
        foreach($result as $k=>$v){
            $result[$k]['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
        }
    }
}